package com.alan.camunda.boot.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * ${handlerChoose.execute()}
 */
@Slf4j
@Component
public class HandlerChoose {

    private volatile List<String> candidateUsers = new ArrayList<>();

    public HandlerChoose() {
        this.candidateUsers.add("demo");
    }

    public void changeCandidateUsers(List<String> candidateUsers) {
        this.candidateUsers = candidateUsers;
    }

    public List<String> showCandidateUsers() {
        return this.candidateUsers;
    }

    public List<String> execute() {
        log.info("HandlerChoose#execute 进行选人操作");
        if (TempUserHolder.hasTempUsers()) {
            return TempUserHolder.getTempUsers();
        }
        return this.candidateUsers;
    }

}
